package dfferber.xstream;

import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;

public interface PojoReflectionProvider {
    /**
     * Write a property of a POJO using the setter access method.
     * @param object
     * @param propertyName
     * @param value
     */
    void setProperty(Object pojoObject, String propertyName, Object value);
    /**
     * Read a property of a POJO using the setter access method.
     * @param object
     * @param propertyName
     * @param value
     */
    Object getProperty(Object pojoObject, String propertyName);
    /**
     * Check if the given object is a POJO.
     * @param object
     * @param propertyName
     * @param value
     */
    boolean isPojo(Class<?> type);
    /**
     * Apply an operation on each property of the POJO.
     * @param object
     * @param visitor
     */
    void visitSerializableProperties(Object pojoObject, Visitor visitor);
	/**
	 * A visitor interface for properties defined in the POJO.
	 */
    interface Visitor {
		void visit(String propertyName, Class<?> propertyType, Class<?> definedIn, Object value, boolean writeAble) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
    }
    /**
     * Returns a property description defined in the POJO.
     * @param definedIn	class where the property was defined
     * @param propertyName	property name
     * @return	the property description itself
     */
	PropertyDescriptor getPropertyDescriptor(Class<?> definedIn, String propertyName);
	boolean canStreamProperty(PropertyDescriptor descriptor);
}
